
import pyautogui
import keyboard
import threading

def getMousePos() :
    x, y = pyautogui.position()
    return (x, y)




Screen_width, Screen_height = pyautogui.size()

print(f"屏幕宽度: {Screen_width}, 屏幕高度: {Screen_height}")



# pyautogui.moveTo(100, 100, duration=1)  # 将鼠标移动到(100, 100)的位置，持续1秒
# pyautogui.click(200, 200)  # 在(200, 200)位置单击鼠标左键
# pyautogui.scroll(10)  # 向上滚动10个单位
# pyautogui.typewrite("Hello, World!")  # 输入文本
# pyautogui.hotkey("ctrl", "c")  # 模拟Ctrl+C
# pyautogui.keyDown("shift")  # 按下Shift键
# pyautogui.keyUp("shift")  # 释放Shift键
# pyautogui.sleep(2)  # 等待2秒

# color = pyautogui.pixel(300, 300) # 获取屏幕上指定位置的像素颜色
# 截取整个屏幕
# screenshot = pyautogui.screenshot()
# screenshot.save('screenshot.png')









on_f10_pressed_actived = False
def process_f10_pressed() :
    global on_f10_pressed_actived
    while True :

        # pyautogui.keyDown("space") 
        # pyautogui.sleep(0.2)
        # pyautogui.sleep(0.5)

        pyautogui.keyDown("j") 
        pyautogui.sleep(0.02)
        pyautogui.keyUp("j") 
        pyautogui.sleep(0.2)
        pyautogui.keyDown("k") 
        pyautogui.keyUp("k") 
        pyautogui.sleep(0.2)
        pyautogui.keyDown("k") 
        pyautogui.keyUp("k") 
        pyautogui.sleep(0.2)
        pyautogui.keyDown("k") 
        pyautogui.keyUp("k") 
        pyautogui.sleep(0.2)
        pyautogui.keyDown("k") 
        pyautogui.keyUp("k") 
        pyautogui.sleep(0.2)
        pyautogui.keyDown("k") 
        pyautogui.keyUp("k") 
        pyautogui.sleep(0.2)
        pyautogui.keyDown("k") 
        pyautogui.keyUp("k") 
        pyautogui.sleep(0.2)
        pyautogui.keyDown("k") 
        pyautogui.keyUp("k") 
        pyautogui.sleep(1.6)
        # pyautogui.keyDown("c") 
        # pyautogui.sleep(0.05)


        if on_f10_pressed_actived == False:
            break
def on_f10_pressed() :
    global on_f10_pressed_actived
    on_f10_pressed_actived = not on_f10_pressed_actived
    if on_f10_pressed_actived:
        print("f10 开启")
        thread = threading.Thread(target=process_f10_pressed)
        thread.start()
    else :
        print("f10 关闭")
keyboard.add_hotkey('f10', on_f10_pressed)


def clear_all_bool(event) :
    if event.name == "esc":
        global on_f10_pressed_actived
        on_f10_pressed_actived = False

                   
keyboard.on_press(clear_all_bool)
                           
keyboard.wait()

                                           
         






